<template>
  <view class="container">
    <view class="big-box"  @click="toPage">
      <image src="/static/big.svg" mode="widthFix"  ></image>
      <text>放大</text>
    </view>
    <scroll-view class="tab-container" scroll-x="true" scroll-left="{{scrollLeft}}">
      <view class="tab-item" v-for="(item, index) in tabs" :key="index" @tap="switchTab(index)">
        {{ item.name }}
      </view>
    </scroll-view>
    <swiper class="swiper-box" :current="currentIndex" @change="swiperChange">
      <swiper-item v-for="(item, index) in tabs" :key="index">
        <view>内容 {{ item.name }}</view>
      </swiper-item>
    </swiper>
  </view>
</template>

<script>
export default {
  data() {
    return {
      tabs: [
        { name: 'Tab1' },
        { name: 'Tab2' },
        { name: 'Tab3' },
        // ...更多tabs
      ],
      currentIndex: 0,
      scrollLeft: 0,
    };
  },
  methods: {
    toPage() {
      uni.navigateTo({
        url: '/pages/component/dzs/detail'
      })
    },
    switchTab(index) {
      this.currentIndex = index;
      this.scrollLeft = (index - 2) * 200; // 假设每个tab的宽度是100px
    },
    swiperChange(e) {
      this.currentIndex = e.detail.current;
    },
  },
};
</script>

<style>
.tab-container {
  white-space: nowrap;
  display: flex;
}
.tab-item {
  display: inline-block;
  width: 100px;
  margin-right: 10px;
  text-align: center;
}
.swiper-box {
  height: 800px; /* 根据实际情况设置高度 */
}
</style>